<include file="../header"/>
<div class="wrapper">
    <div class="header text-center font-16">
        申请
        <div class="iconfont icon-zuo go_back"></div>
    </div>
    <div class="history-list">
        <div class="repair-list gray">
            <select name="" id="position">
                <option value="1">维修工</option>
                <option value="2">维修主管</option>
            </select>

            <div class="iconfont icon-zuo-copy "></div>
        </div>
        <div class="repair-list gray2">
            <input type="text" placeholder="请输入姓名" id="real_name">
        </div>
        <div class="repair-list gray2">
            <input type="text" placeholder="请输入手机号" id="mobile">
        </div>
    </div>
    <a href="#" class="btn text-center order_receiving">提交</a>
    <input type="hidden" id="is_submit" value="0">
</div>
<include file="../footer"/>
<script src="/assets/repaireast/js/layer.js"></script>
<script src="/assets/repaireast/js/public.js"></script>
<script>

    $('.btn').click(function () {
        var real_name = $('#real_name').val();
        if (!real_name) {
            fm.alert('请输入姓名！');
            return false;
        }
        var mobile = $('#mobile').val();
        if (!mobile) {
            fm.alert('手机号不能为空！');
            return false;
        }
        var reg = /^(((13[0-9]{1})|(15[0-9]{1})|(17[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
        if (!reg.test(mobile)) {
            fm.alert('手机号格式有误！');
            return false;
        }
        var position = $('#position').val();

        //防止重复提交
        var is_submit = $('#is_submit').val();
        $('#is_submit').val(1);
        if (is_submit == 0){
            $.ajax({
                type: 'post',
                url: "/Repaireast/RepaireastRegister/doRegister",
                dataType: 'json',
                data: {
                    'real_name': real_name,
                    'mobile': mobile,
                    'position':position
                },
                success: function (data) {
                    if (data.status == 'S') {
                        setTimeout(function () {
                            var url = '/Repaireast/Repaireast/tips';
                            window.location.href = url;
                        }, 2000);
                    } else {
                        fm.alert(data.message);
                    }
                    $('#is_submit').val(0);
                },
                error: function () {
                    fm.alert('通讯失败，请稍后再试');
                    $('#is_submit').val(0);
                }
            });
        }
    })
</script>